import { defineStore } from '../../../lib/main'


// 只有 state 的 ，函数
export const useState10 = () =>  defineStore('state10', {
  state: () => {
    return {
      name: '基础设置',
      age: 20
    }
  }
})

// 只有 state 的，对象
export const useState11 = () => defineStore('state11', {
  state: {
    name: '基础设置',
    age: 20
  } 
})

// 只有 state 的，数组
export const useState12 = () => defineStore('state12', {
  state: [{
    name: '基础设置',
    age: 20
  }]
})

// 直接是 state 的
export const useState13 = () => defineStore('state13', {
  name: '基础设置',
  age: 20
})

// 直接是 state 的
export const useState14 = () => defineStore('state14', [
  {
    name: '基础设置',
    age: 20
  }
])

// state、getter、action，state 是函数的
export const useState20 = () => defineStore('state20', {
  state: () => {
    return {
      name: '基础设置',
      age: 20
    }
  },
  getters: {
    getName() {
      return this.name + ' + 普通函数'
    },
    getAge: (state: any) => {
      return state.age + ' + 箭头函数'
    }

  },
  actions: {
    addAge(n = 1) {
      this.age += n

    },
    addAge2: (state: any, n = 1 ) => {
      state.age += 10 * n
    }
  },
  options: {
    isLog: false
  }
})


// state 是对象的
export const useState21 = () => defineStore('state21', {
  state: {
    name: '基础设置',
    age: 20
  },
  getters: {
    getName() {
      return this.name + ' + 普通函数'
    },
    getAge: (state: any) => {
      return state.age + ' + 箭头函数'
    }

  },
  actions: {
    addAge(n = 1) {
      this.age += n

    },
    addAge2: (state: any, n = 1 ) => {
      state.age += 10 * n
    }
  },
  options: {
    isLog: false
  }
})
 